<script>
	export default {
		data(){
			return{
				globalURL:this.$websiteUrl,
				_url:this.$websiteUrl+"/wxLogin",
				gameData:""
					
			}
		},
		methods:{
			//获取图片链接前缀
			getImageUrlPrefix(){
				return this.$websiteUrl+'/img/photo/';
			},
			//登录
			_login(){
				var that = this;
				//获取已经有的token
				wx.getStorage({
				  key: 'token',
				  //已经有token
				  success (res) {
				    console.log(res.data)
				  },
				  //没有token
				  fail(){
					  console.log("当前没有登录token--")
					  //获取code
					  uni.login({
					    provider:"weixin",
					    success: function (resp) {
					  	console.log("res_code"+resp.code);
					  	//通过code请求后台接口,获取会话id
					  	uni.request({
					  	    url: that._url,
					  	    data: {
					  			code:resp.code
					  	    },
					  		method: 'POST',
					  	    success: (res) => {
					  			wx.setStorage({
					  			  key:"token",
					  			  data:res.data.token
					  			});
					  	    }
					  	});
					    }
					  });
				  }
				});
				
			}
		},
		onLaunch: function() {
			// console.log("请求之前");
			// console.log(this.$data._url);		
			// //this._login();
			
			// console.log("请求之后1");
			console.log('App Launch');
		},
		onShow: function() {
			console.log('App Show');
			
			
		},
		onHide: function() {
			console.log('App Hide')
			
		}
	
	}
</script>

<style>
	/*每个页面公共css */
</style>
